import cv2 as cv
import numpy as np
def main():

    # 读入图像
    im = cv.imread('123.png')
    # 将图像转为灰度图像
    im_grey = cv.cvtColor(im, cv.COLOR_BGR2GRAY)

    # 对图像进行高斯平滑
    im_grey = cv.GaussianBlur(im_grey, (3, 3), 0, 0)
    # Laplacian边缘检测。注意输出图像的数据类型
    im_laplacian_1  = cv.Laplacian(im_grey, cv.CV_32F, 1)
    im_laplacian_3 = cv.Laplacian(im_grey, cv.CV_32F, 3)
    # 将图像转换为8位图像，用于显示
    im_laplacian_1 = cv.convertScaleAbs(im_laplacian_1)
    im_laplacian_3 = cv.convertScaleAbs(im_laplacian_3)

    cv.imshow('blox_laplacian1.jpg', im_laplacian_1)
    cv.imshow('blox_laplacian3.jpg', im_laplacian_3)
    cv.waitKey()
    cv.destroyAllWindows()


if __name__ == '__main__':
    main()